package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.GwcBean;
import com.lwj.liwanjia.impl.GwcView;
import com.lwj.liwanjia.model.GwcModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/1.
 */

public class GwcPresenter {
    private GwcModel gwcModel;
    private GwcView gwcView;

    public GwcPresenter(GwcView gwcView) {
        this.gwcView = gwcView;
        gwcModel = new GwcModel();
    }

    public void getGwcData(String token) {
        if (gwcView != null) {
            gwcModel.getGwcData(token, new Subscriber<GwcBean>() {
                @Override
                public void onCompleted() {
                    gwcView.hideProgress();
                }

                @Override
                public void onError(Throwable e) {
                    gwcView.showError((Exception) e);
                    gwcView.hideProgress();
                }

                @Override
                public void onNext(GwcBean gwcBean) {
                    gwcView.getGwcData(gwcBean);
                }

                @Override
                public void onStart() {
                    super.onStart();
                    gwcView.showProgress();
                }
            });
        }
    }
}
